﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using System.ComponentModel;

namespace WorkflowDesignerApp
{
    class YhEdit : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null && context.Instance != null)
            {
                return UITypeEditorEditStyle.Modal;
            }

            return base.GetEditStyle(context);
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (context != null && context.Instance != null && provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    if ((context.Instance as 等待审批提交) != null)
                    {
                        等待审批提交 control = (等待审批提交)context.Instance;
                        FrmChoiceYh dlg = new FrmChoiceYh(control.处理人);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            value = dlg.result;
                        }
                        return value;
                    }
                    else if ((context.Instance as 打回重新修改) != null)
                    {
                        打回重新修改 control = (打回重新修改)context.Instance;
                        FrmChoiceYh dlg = new FrmChoiceYh(control.处理人);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            value = dlg.result;
                        }
                        return value;
                    }
                    else if ((context.Instance as 取消) != null)
                    {
                        取消 control = (取消)context.Instance;
                        FrmChoiceYh dlg = new FrmChoiceYh(control.处理人);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            value = dlg.result;
                        }
                        return value;
                    }
                    else if ((context.Instance as 等待) != null)
                    {
                        等待 control = (等待)context.Instance;
                        FrmChoiceYh dlg = new FrmChoiceYh(control.处理人);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            value = dlg.result;
                        }
                        return value;
                    }
                    else if ((context.Instance as 加签) != null)
                    {
                        加签 control = (加签)context.Instance;
                        FrmChoiceYh dlg = new FrmChoiceYh(control.处理人);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            value = dlg.result;
                        }
                        return value;
                    }
                }
            }

            return value;
        }

    }
}
